using System;
using System.Collections.Generic;

using AzureContrib.WindowsAzure.ServiceRuntime.ServiceLocation;

namespace AzureContrib.WindowsAzure.Tests.Mocks
{
	/// <summary>
	/// A mock <see cref="IBuilder"/>.
	/// </summary>
	public class MockBuilder : IBuilder
	{
		/// <summary>
		/// A mock <see cref="IBuilder"/>.
		/// </summary>
		public IDictionary<Type, Action<object>> BuildUpActions;

		/// <summary>
		/// A mock <see cref="IBuilder"/>.
		/// </summary>
		public IList<object> BuildUpCalls;

		/// <summary>
		/// A mock <see cref="IBuilder"/>.
		/// </summary>
		public MockBuilder()
		{
			BuildUpCalls = new List<object>();
			BuildUpActions = new Dictionary<Type, Action<object>>();
		}

		/// <summary>
		/// A mock <see cref="IBuilder"/>.
		/// </summary>
		public void BuildUp(object instanceToBuild)
		{
			BuildUpCalls.Add(instanceToBuild);
			BuildUpActions[instanceToBuild.GetType()](instanceToBuild);
		}
	}
}